print("hello word")

var myVariable = 42
myVariable = 50
let myConstant = 42

print(myVariable)
print(myConstant)

//转换-推算

let strLet = "let strLet"
let width = 98
let widthStrLet = strLet + String(width)

print(strLet)
print(width)
print(widthStrLet)

//插值字符转
print("Hello \(strLet + String(width)) !!")

//多行字符转

let mathStr = """
Hello 
\(strLet + String(width)) 
!!
"""
print(mathStr)

//数组和字典
var shoppingList = ["catfish", "water", "tulips", "blue paint"]
shoppingList[1] = "bottle of water"

var occupations = [
    "Malcolm": "Captain",
    "Kaylee": "Mechanic",
]
occupations["Jayne"] = "Public Relations"

print(shoppingList)
print(occupations)

//初始化NULL语法
print([String]())
print([String: Float]())

//for in 循环

var forCount = 0
for it in [1,2,3,4,5,65,6] {
	if it > 1 {
		forCount+=3
	}else {
		forCount+=1
	}
}
print(forCount)

var optionalName: String? = "John Appleseed"
if let name = optionalName {
	print("name, \(name)")
}

// Null 默认值
let nickName: String? = nil
let fullName: String = "John Appleseed"
let informalGreeting = "Hi \(nickName ?? fullName)"
print(informalGreeting)